<template>
  <div>
    <el-card>
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        class="zdy-form search-form-new"
        label-width="68px"
      >
        <el-form-item label="推送渠道" prop="saleId">
          <el-select
            v-model="queryParams.saleId"
            placeholder="请选择推送渠道"
            size="small"
            clearable
            filterable
          >
            <!-- @change="changefn" -->
            <el-option
              v-for="dict in pushAllListNew"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="游戏名称" prop="gameId">
          <el-select
            v-model="queryParams.gameId"
            placeholder="请选择游戏"
            size="small"
            clearable
          >
            <el-option
              v-for="dict in list"
              :key="dict.id"
              :label="dict.gameName"
              :value="dict.gameId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="号商账号" prop="goodsNo">
          <el-input
            v-model="queryParams.goodsNo"
            placeholder="请输入号商账号"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            class="zdy-btn"
            @click="sousuo"
            >搜索</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button
            icon="el-icon-refresh"
            type="primary"
            size="mini"
            plain
            @click="chongzhi"
            class="zdy-btn zdy-btn-refresh"
            >重置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table border :data="tableList" style="width: 100%">
        <el-table-column prop="" label="错误信息" align="center">
          <template #default="{ row }">
            {{ row.outGoodsNo }} - {{ row.errorCode }} - {{ row.errorMessage }}
          </template>
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="创建时间"
          width="188"
          align="center"
        >
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getGameList, allList } from "@/api/partner/InterfaceErrorMessage";
import goodsListApi from "@/api/gameConfig/goodsList";
export default {
  data() {
    return {
      list: [],
      queryParams: {
        goodsNo: null,
        gameId: null,
        saleId: null,
      },
      pushAllListNew: [],
      tableList: [],
      //   form: {
      //     goodsNo: null,
      //     gameId: null,
      //     salePartner: null,
      //   },
    };
  },
  created() {
    this.getList();
    this.getPushListNew();
  },
  methods: {
    // 获取推送渠道
    getPushListNew() {
      goodsListApi.pushAllList().then((res) => {
        this.pushAllListNew = res.rows;
      });
    },
    async getList() {
      const res = await getGameList();
      console.log("res", res);
      this.list = res;
    },
    // async changefn(e) {
    //   const arr = this.pushAllListNew.filter((item) => item.name == e);
    //   console.log("arr", arr);
    //   if (arr && arr.length != 0) {
    //     this.form.salePartner = arr[0].id;
    //   }
    // },
    async sousuo() {
      if (!this.queryParams.saleId) {
        return this.$message.error("请选择推送渠道！");
      }
      if (!this.queryParams.gameId) {
        return this.$message.error("请选择游戏！");
      }
      if (!this.queryParams.goodsNo) {
        return this.$message.error("请输入号商账号！");
      }
      const res = await allList(this.queryParams);
      console.log("res", res);
      let data = JSON.parse(res.msg);
      //   console.log('data',data);
      this.tableList = data.data;
    },
    chongzhi() {
      this.queryParams = {
        goodsNo: null,
        gameId: null,
        saleId: null,
      };
      this.tableList = [];
    },
  },
};
</script>

<style>
</style>